home *** CD-ROM | disk | FTP | other *** search
- package javax.help;
-
- import java.awt.Button;
- import java.awt.Component;
- import java.awt.Dialog;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.IllegalComponentStateException;
- import java.awt.MenuItem;
- import java.awt.Point;
- import java.awt.Window;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
- import java.awt.event.WindowListener;
- import java.lang.reflect.Constructor;
- import java.lang.reflect.InvocationTargetException;
- import java.lang.reflect.Method;
- import java.net.URL;
- import java.util.Enumeration;
- import java.util.Locale;
- import javax.help.Map.ID;
- import javax.swing.AbstractButton;
- import javax.swing.JComponent;
- import javax.swing.JDialog;
- import javax.swing.JFrame;
- import javax.swing.KeyStroke;
-
- public class DefaultHelpBroker implements HelpBroker, KeyListener {
- protected HelpSet helpset = null;
- protected JFrame frame = null;
- protected JHelp jhelp = null;
- protected Locale locale = null;
- protected Font font = null;
- protected JDialog dialog = null;
- protected Window ownerWindow = null;
- protected boolean modallyActivated = false;
- static boolean on1dot1 = true;
- private int HELP_WIDTH = 645;
- private int HELP_HEIGHT = 495;
- // $FF: renamed from: dl java.awt.event.WindowListener
- WindowListener field_0;
- boolean modalDeactivated = true;
- protected ActionListener displayHelpFromFocus;
- protected ActionListener displayHelpFromSource;
- private static final boolean debug = false;
- // $FF: synthetic field
- static Class class$java$awt$Dialog;
- // $FF: synthetic field
- static Class class$javax$swing$JDialog;
- // $FF: synthetic field
- static Class class$java$awt$Frame;
- // $FF: synthetic field
- static Class class$java$awt$Window;
-
- public DefaultHelpBroker(HelpSet var1) {
- this.setHelpSet(var1);
- }
-
- public DefaultHelpBroker() {
- }
-
- public HelpSet getHelpSet() {
- return this.helpset;
- }
-
- public void setHelpSet(HelpSet var1) {
- if (var1 != null && this.helpset != var1) {
- if (this.jhelp != null) {
- DefaultHelpModel var2 = new DefaultHelpModel(var1);
- this.jhelp.setModel(var2);
- }
-
- this.helpset = var1;
- }
-
- }
-
- public Locale getLocale() {
- return this.locale == null ? Locale.getDefault() : this.locale;
- }
-
- public void setLocale(Locale var1) {
- this.locale = var1;
- if (this.jhelp != null) {
- this.jhelp.setLocale(this.locale);
- }
-
- }
-
- public Font getFont() {
- this.createHelpWindow();
- return this.font == null ? this.jhelp.getFont() : this.font;
- }
-
- public void setFont(Font var1) {
- this.font = var1;
- if (this.jhelp != null) {
- this.jhelp.setFont(this.font);
- }
-
- }
-
- public void setCurrentView(String var1) {
- this.createHelpWindow();
- JHelpNavigator var2 = null;
-
- for(Enumeration var3 = this.jhelp.getHelpNavigators(); var3.hasMoreElements(); var2 = null) {
- var2 = (JHelpNavigator)var3.nextElement();
- if (var2.getNavigatorName().equals(var1)) {
- break;
- }
- }
-
- if (var2 == null) {
- throw new IllegalArgumentException("Invalid view name");
- } else {
- this.jhelp.setCurrentNavigator(var2);
- }
- }
-
- public String getCurrentView() {
- this.createHelpWindow();
- return this.jhelp.getCurrentNavigator().getNavigatorName();
- }
-
- public void initPresentation() {
- this.createHelpWindow();
- }
-
- public void setDisplayed(boolean var1) {
- debug("setDisplayed");
- this.createHelpWindow();
- if (this.modallyActivated) {
- if (var1) {
- this.dialog.show();
- } else {
- this.dialog.hide();
- }
- } else {
- this.frame.setVisible(var1);
-
- try {
- Class[] var2 = new Class[]{Integer.TYPE};
- Method var3 = (class$java$awt$Frame == null ? (class$java$awt$Frame = class$("java.awt.Frame")) : class$java$awt$Frame).getMethod("setState", var2);
- if (var3 != null) {
- Object[] var4 = new Object[]{new Integer(0)};
- var3.invoke(this.frame, var4);
- }
- } catch (NoSuchMethodError var6) {
- } catch (NoSuchMethodException var7) {
- } catch (InvocationTargetException var8) {
- } catch (IllegalAccessException var9) {
- }
- }
-
- }
-
- public boolean isDisplayed() {
- if (this.modallyActivated) {
- return this.dialog != null ? this.dialog.isShowing() : false;
- } else if (this.frame != null) {
- if (!this.frame.isVisible()) {
- return false;
- } else {
- try {
- Method var1 = (class$java$awt$Frame == null ? (class$java$awt$Frame = class$("java.awt.Frame")) : class$java$awt$Frame).getMethod("getState", (Class[])null);
- if (var1 != null) {
- int var2 = (Integer)var1.invoke(this.frame, (Object[])null);
- if (var2 == 0) {
- return true;
- }
-
- return false;
- }
- } catch (NoSuchMethodError var5) {
- } catch (NoSuchMethodException var6) {
- } catch (InvocationTargetException var7) {
- } catch (IllegalAccessException var8) {
- }
-
- return true;
- }
- } else {
- return false;
- }
- }
-
- public void setLocation(Point var1) throws UnsupportedOperationException {
- this.createHelpWindow();
- if (this.modallyActivated) {
- this.dialog.setLocation(var1);
- } else {
- this.frame.setLocation(var1);
- }
-
- }
-
- public Point getLocation() throws UnsupportedOperationException {
- if (this.jhelp == null) {
- throw new IllegalComponentStateException("presentation not displayed");
- } else {
- if (this.modallyActivated) {
- if (this.dialog != null) {
- return this.dialog.getLocation();
- }
- } else if (this.frame != null) {
- return this.frame.getLocation();
- }
-
- return null;
- }
- }
-
- public void setSize(Dimension var1) throws UnsupportedOperationException {
- this.HELP_WIDTH = var1.width;
- this.HELP_HEIGHT = var1.height;
- this.createHelpWindow();
- if (this.modallyActivated) {
- this.dialog.setSize(var1);
- this.dialog.validate();
- } else {
- this.frame.setSize(var1);
- this.frame.validate();
- }
-
- }
-
- public Dimension getSize() throws UnsupportedOperationException {
- if (this.jhelp == null) {
- throw new IllegalComponentStateException("presentation not displayed");
- } else {
- if (this.modallyActivated) {
- if (this.dialog != null) {
- return this.dialog.getSize();
- }
- } else if (this.frame != null) {
- return this.frame.getSize();
- }
-
- return null;
- }
- }
-
- public void setViewDisplayed(boolean var1) {
- this.createHelpWindow();
- this.jhelp.setNavigatorDisplayed(var1);
- }
-
- public boolean isViewDisplayed() {
- this.createHelpWindow();
- return this.jhelp.isNavigatorDisplayed();
- }
-
- public void setCurrentID(String var1) throws BadIDException {
- try {
- this.setCurrentID(ID.create(var1, this.helpset));
- } catch (InvalidHelpSetContextException var3) {
- new Error("internal error?");
- }
-
- }
-
- public void setCurrentID(Map.ID var1) throws InvalidHelpSetContextException {
- debug("setCurrentID");
- this.createJHelp();
- this.jhelp.getModel().setCurrentID(var1);
- }
-
- public Map.ID getCurrentID() {
- return this.jhelp != null ? this.jhelp.getModel().getCurrentID() : null;
- }
-
- public void setCurrentURL(URL var1) {
- this.createHelpWindow();
- this.jhelp.getModel().setCurrentURL(var1);
- if (this.modallyActivated) {
- this.dialog.setVisible(true);
- this.dialog.show();
- } else {
- this.frame.setVisible(true);
- this.frame.show();
- }
-
- }
-
- public URL getCurrentURL() {
- return this.jhelp.getModel().getCurrentURL();
- }
-
- public void enableHelpKey(Component var1, String var2, HelpSet var3) {
- if (var2 == null) {
- throw new NullPointerException("id");
- } else {
- CSH.setHelpIDString(var1, var2);
- if (var3 != null) {
- CSH.setHelpSet(var1, var3);
- }
-
- if (var1 instanceof JComponent) {
- JComponent var4 = (JComponent)var1;
- var4.registerKeyboardAction(this.getDisplayHelpFromFocus(), KeyStroke.getKeyStroke(156, 0), 1);
- var4.registerKeyboardAction(this.getDisplayHelpFromFocus(), KeyStroke.getKeyStroke(112, 0), 1);
- } else {
- var1.addKeyListener(this);
- }
-
- }
- }
-
- public void keyTyped(KeyEvent var1) {
- }
-
- public void keyPressed(KeyEvent var1) {
- }
-
- public void keyReleased(KeyEvent var1) {
- int var2 = var1.getKeyCode();
- if (var2 == 112 || var2 == 156) {
- ActionListener var3 = this.getDisplayHelpFromFocus();
- var3.actionPerformed(new ActionEvent(var1.getComponent(), 1001, (String)null));
- }
-
- }
-
- public void enableHelp(Component var1, String var2, HelpSet var3) {
- if (var2 == null) {
- throw new NullPointerException("id");
- } else {
- CSH.setHelpIDString(var1, var2);
- if (var3 != null) {
- CSH.setHelpSet(var1, var3);
- }
-
- }
- }
-
- public void enableHelp(MenuItem var1, String var2, HelpSet var3) {
- if (var2 == null) {
- throw new NullPointerException("id");
- } else {
- CSH.setHelpIDString(var1, var2);
- if (var3 != null) {
- CSH.setHelpSet(var1, var3);
- }
-
- }
- }
-
- public void enableHelpOnButton(Component var1, String var2, HelpSet var3) {
- if (!(var1 instanceof AbstractButton) && !(var1 instanceof Button)) {
- throw new IllegalArgumentException("Invalid Component");
- } else if (var2 == null) {
- throw new NullPointerException("id");
- } else {
- CSH.setHelpIDString(var1, var2);
- if (var3 != null) {
- CSH.setHelpSet(var1, var3);
- }
-
- if (var1 instanceof AbstractButton) {
- AbstractButton var4 = (AbstractButton)var1;
- var4.addActionListener(this.getDisplayHelpFromSource());
- } else if (var1 instanceof Button) {
- Button var5 = (Button)var1;
- var5.addActionListener(this.getDisplayHelpFromSource());
- }
-
- }
- }
-
- public void enableHelpOnButton(MenuItem var1, String var2, HelpSet var3) {
- if (var1 == null) {
- throw new IllegalArgumentException("Invalid Component");
- } else if (var2 == null) {
- throw new NullPointerException("id");
- } else {
- CSH.setHelpIDString(var1, var2);
- if (var3 != null) {
- CSH.setHelpSet(var1, var3);
- }
-
- var1.addActionListener(this.getDisplayHelpFromSource());
- }
- }
-
- protected ActionListener getDisplayHelpFromFocus() {
- if (this.displayHelpFromFocus == null) {
- this.displayHelpFromFocus = new CSH.DisplayHelpFromFocus(this);
- }
-
- return this.displayHelpFromFocus;
- }
-
- protected ActionListener getDisplayHelpFromSource() {
- if (this.displayHelpFromSource == null) {
- this.displayHelpFromSource = new CSH.DisplayHelpFromSource(this);
- }
-
- return this.displayHelpFromSource;
- }
-
- public void setActivationWindow(Window var1) {
- if (var1 != null && var1 instanceof Dialog) {
- Dialog var2 = (Dialog)var1;
- if (var2.isModal()) {
- this.ownerWindow = var1;
- this.modallyActivated = true;
- } else {
- this.ownerWindow = null;
- this.modallyActivated = false;
- }
- } else {
- this.ownerWindow = null;
- this.modallyActivated = false;
- }
-
- }
-
- private synchronized void createJHelp() {
- debug("createJHelp");
- if (this.jhelp == null) {
- this.jhelp = new JHelp(this.helpset);
- if (this.font != null) {
- this.jhelp.setFont(this.font);
- }
-
- if (this.locale != null) {
- this.jhelp.setLocale(this.locale);
- }
- }
-
- }
-
- private synchronized void createHelpWindow() {
- debug("createHelpWindow");
- Point var1 = null;
- Dimension var2 = null;
- JDialog var3 = null;
- this.createJHelp();
- String var4 = this.helpset.getTitle();
- if (this.modallyActivated) {
- Window var5 = null;
-
- try {
- Method var6 = (class$java$awt$Window == null ? (class$java$awt$Window = class$("java.awt.Window")) : class$java$awt$Window).getMethod("getOwner", (Class[])null);
- if (var6 != null && this.dialog != null) {
- var5 = (Window)var6.invoke(this.dialog, (Object[])null);
- }
- } catch (NoSuchMethodError var10) {
- } catch (NoSuchMethodException var11) {
- } catch (InvocationTargetException var12) {
- } catch (IllegalAccessException var13) {
- }
-
- if (this.dialog == null || var5 != this.ownerWindow || this.modalDeactivated) {
- if (this.frame != null) {
- var1 = this.frame.getLocation();
- var2 = this.frame.getSize();
- this.frame.dispose();
- }
-
- if (this.dialog != null) {
- var1 = this.dialog.getLocation();
- var2 = this.dialog.getSize();
- var3 = this.dialog;
- }
-
- if (on1dot1) {
- this.dialog = new JDialog();
- this.dialog.setTitle(var4);
- } else {
- this.dialog = new JDialog((Dialog)this.ownerWindow, var4);
- this.field_0 = new 1(this);
- debug("adding windowlistener");
- this.ownerWindow.addWindowListener(this.field_0);
- this.modalDeactivated = false;
- }
-
- if (var2 != null) {
- this.dialog.setSize(var2);
- } else {
- this.dialog.setSize(this.HELP_WIDTH, this.HELP_HEIGHT);
- }
-
- if (var1 != null) {
- this.dialog.setLocation(var1);
- }
-
- this.dialog.getContentPane().add(this.jhelp);
- if (var3 != null) {
- var3.dispose();
- }
- }
- } else {
- if (this.frame == null) {
- this.frame = new JFrame(var4);
- 2 var14 = new 2(this);
- this.frame.addWindowListener(var14);
- }
-
- if (this.dialog != null) {
- var1 = this.dialog.getLocation();
- var2 = this.dialog.getSize();
- this.dialog.dispose();
- this.dialog = null;
- this.ownerWindow = null;
- }
-
- if (var2 != null) {
- this.frame.setSize(var2);
- } else {
- this.frame.setSize(this.HELP_WIDTH, this.HELP_HEIGHT);
- }
-
- if (var1 != null) {
- this.frame.setLocation(var1);
- }
-
- this.frame.getContentPane().add(this.jhelp);
- this.frame.setTitle(this.helpset.getTitle());
- }
-
- }
-
- private static void debug(Object var0) {
- }
-
- // $FF: synthetic method
- static Class class$(String var0) {
- try {
- return Class.forName(var0);
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(var2.getMessage());
- }
- }
-
- // $FF: synthetic method
- static void access$000(Object var0) {
- debug(var0);
- }
-
- static {
- try {
- Class[] var0 = new Class[]{class$java$awt$Dialog == null ? (class$java$awt$Dialog = class$("java.awt.Dialog")) : class$java$awt$Dialog, Boolean.TYPE};
- Constructor var1 = (class$javax$swing$JDialog == null ? (class$javax$swing$JDialog = class$("javax.swing.JDialog")) : class$javax$swing$JDialog).getConstructor(var0);
- on1dot1 = var1 == null;
- } catch (NoSuchMethodException var2) {
- on1dot1 = true;
- }
-
- SwingHelpUtilities.installLookAndFeelDefaults();
- }
- }
-